package org.jdcenter.server.xb;
/**
 * @author miao
 * @since 2008-11-27
 *
 */
import org.jdcenter.server.xb.metadata.MateData;
import org.jdcenter.server.xb.parser.AbstractParser;

public class ParserFactory {
	
	private static ParserFactory parserFactory = null;
	
	private ParserFactory(){}
	
	public static ParserFactory getInstance(){
		if(parserFactory == null){
			parserFactory = new ParserFactory();
		}
		return parserFactory;
	}
	public <T extends MateData> AbstractParser<T> createParser(String parserName,ClassLoader loader) throws ClassNotFoundException, InstantiationException, IllegalAccessException{
		if(parserName == null){
			throw new IllegalArgumentException("XML parser is wrong");
		}
		Class parser = Class.forName(parserName,true,loader);
		return (AbstractParser<T>)parser.newInstance();
	}

}
